Skip to content

Fix report page: update allowed domains and repair image upload#20

Merged
ziggy-mc merged 2 commits intomainfrom
copilot/update-report-page-links
Mar 12, 2026
Merged

Fix report page: update allowed domains and repair image upload#20
ziggy-mc merged 2 commits intomainfrom
copilot/update-report-page-links

Conversation

Copy link
Contributor

Copilot AI commented Mar 12, 2026

  • Create pages/404.js with: "This short URL either expired or doesn't exist" message, spinner icon, "Redirecting..." text, 1.75s redirect to home page
  • Update pages/[code].js to use { notFound: true } instead of redirecting to PRIMARY_DOMAIN?error=notfound / ?error=expired

📱 Kick off Copilot coding agent tasks wherever you are with GitHub Mobile, available on iOS and Android.

@vercel
Copy link

vercel bot commented Mar 12, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
zmcdsc Ready Ready Preview, Comment Mar 12, 2026 11:24pm

Co-authored-by: ziggy-mc <213874544+ziggy-mc@users.noreply.github.com>
Copilot AI changed the title [WIP] Update report page to use new links and remove old domain Fix report page: update allowed domains and repair image upload Mar 12, 2026
Copilot AI requested a review from ziggy-mc March 12, 2026 23:24
Copilot stopped work on behalf of ziggy-mc due to an error March 12, 2026 23:25
@ziggy-mc ziggy-mc marked this pull request as ready for review March 12, 2026 23:29
Copilot AI review requested due to automatic review settings March 12, 2026 23:29
@ziggy-mc ziggy-mc merged commit 1139b6e into main Mar 12, 2026
2 of 4 checks passed
Copilot stopped work on behalf of ziggy-mc due to an error March 12, 2026 23:29
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the link-reporting flow by expanding the list of allowed short-link domains and changing how optional supporting images are attached to reports (switching from a missing upload endpoint to embedding image data in the report payload).

Changes:

  • Update the report page and report API to allow additional service domains.
  • Change report-image handling to convert the selected file to a base64 data URL and submit it inline.
  • Increase the report API request body size limit to accommodate image data.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 6 comments.

File Description
pages/report.js Updates allowed domains and changes client-side image handling to base64 + JSON submit.
pages/api/report/index.js Updates allowed domains and increases body parser size limit for image payloads.
Comments suppressed due to low confidence (1)

pages/report.js:104

  • await res.json() will throw if the API responds with a non-JSON body (common for 413 Payload Too Large or some proxy errors), and the catch then shows a generic "Network error". Consider parsing JSON defensively (fallback to res.text()), so users get an actionable error when uploads are rejected.
      const res = await fetch("/api/report", {
        method: "POST",
        headers: { "Content-Type": "application/json" },
        body: JSON.stringify({
          reportedLink: reportedLink.trim(),
          shortCode,
          reason: reason.trim(),
          imageUrl,
        }),
      });

      const data = await res.json();

      if (!res.ok) {
        setError(data.error || "Failed to submit report. Please try again.");
      } else {

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

import DSReport from "../../../models/DSReport";

const ALLOWED_DOMAINS = ["zmcdsc.vercel.app", "dscs.ziggymc.me"];
const ALLOWED_DOMAINS = ["dscs.ziggymc.me", "invs.ziggymc.me", "ds.ziggymc.me", "d.ziggymc.me"];
export const config = {
api: {
bodyParser: {
sizeLimit: "6mb",
Comment on lines +8 to +14
export const config = {
api: {
bodyParser: {
sizeLimit: "6mb",
},
},
};
import styles from "../styles/Report.module.css";

const ALLOWED_DOMAINS = ["zmcdsc.vercel.app", "dscs.ziggymc.me"];
const ALLOWED_DOMAINS = ["dscs.ziggymc.me", "invs.ziggymc.me", "ds.ziggymc.me", "d.ziggymc.me"];
import styles from "../styles/Report.module.css";

const ALLOWED_DOMAINS = ["zmcdsc.vercel.app", "dscs.ziggymc.me"];
const ALLOWED_DOMAINS = ["dscs.ziggymc.me", "invs.ziggymc.me", "ds.ziggymc.me", "d.ziggymc.me"];
Comment on lines +75 to +86
const MAX_IMAGE_BYTES = 4 * 1024 * 1024;
if (imageFile.size > MAX_IMAGE_BYTES) {
setError("Image must be 4 MB or smaller.");
setLoading(false);
return;
}
// If upload fails, proceed without image
imageUrl = await new Promise((resolve, reject) => {
const reader = new FileReader();
reader.onload = () => resolve(reader.result);
reader.onerror = () => reject(new Error("Failed to read image file."));
reader.readAsDataURL(imageFile);
});
@ziggy-mc ziggy-mc deleted the copilot/update-report-page-links branch March 18, 2026 00:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants